<?php

namespace module\app\controller;

use app\Controller;
use app\model\User as Model;


class Me extends Controller
{
    /**
     * 个人中心.
     * 
     */
    public function index()
    {
        $model = Model::scope('user')->field([
            'nickname', 'birthday', 'career', 'gender', 'aim', 'hobby'
        ])->findOrFail();
        return json($model->toArray());
    }
    /**
     * 详情.
     * 
     */
    public function read()
    {
        $model = Model::scope('user')->field([
            'avatar', 'nickname', 'birthday', 'career', 'gender', 'aim', 'hobby'
        ])->findOrFail();
        return json($model->toArray());
    }
    /**
     * 更新.
     */
    public function update()
    {
        $model = Model::scope('user')->findOrFail();
        $model->save($this->request->put());
        return json($model->toArray());
    }
    /**
     * 删除.
     * 
     */
    public function del()
    {
        $model = Model::scope('user')->findOrFail();
        $model->delete();
        return json($model->toArray());
    }
    /**
     * 第一步.
     */
    public function first()
    {
        $model = Model::scope('user')->findOrFail();
        $model->save($this->request->put());
        return json($model->toArray());
    }
    /**
     * 第二步.
     */
    public function second()
    {
        $model = Model::scope('user')->findOrFail();
        $model->save($this->request->put());
        return json($model->toArray());
    }
    /**
     * 第三步.
     */
    public function three()
    {
        $model = Model::scope('user')->findOrFail();
        $model->save($this->request->put());
        return json($model->toArray());
    }
}


